package com.stxx.framwork.sql;

import cn.hutool.db.sql.SqlExecutor;
import lombok.extern.slf4j.Slf4j;
import org.noear.solon.annotation.Component;
import org.noear.solon.data.sql.intercept.SqlCommandInterceptor;
import org.noear.solon.data.sql.intercept.SqlCommandInvocation;

import javax.sql.DataSource;
import java.sql.SQLException;
import java.util.Arrays;

/**
 * @author Fuzhenlei
 * @date 2025/02/06 10:24
 */
@Slf4j
@Component
public class SqlUtilsFactoryImpl  implements SqlCommandInterceptor {
    @Override
    public Object doIntercept(SqlCommandInvocation inv) throws SQLException {
        System.out.println("sql:" + inv.getCommand().getSql());
        if (inv.getCommand().isBatch()) {
            System.out.println("args:" + inv.getCommand().getArgsColl());
        } else {
            System.out.println("args:" + inv.getCommand().getArgs());
        }
        System.out.println("----------");


        return inv.invoke();
    }
}
